<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

/**
 * @package  SefTranslate
 * Date: 2011/04/01
 * Development Aleksey Pakholkov, Andrey Kvasnevskiy - OrdaSoft(http://ordasoft.com)
 * @copyright 2011 Andrey Kvasnevskiy-OrdaSoft(akbet@mail.ru); 
 * Homepage: http://www.ordasoft.com
 * @version: 2.0.0 Pro 
 */


require_once ( JPATH_SITE .DS.'libraries'.DS.'joomla'.DS.'database'.DS.'table.php' );


/**
* mosSefurl database table class
*/
class mosSefurl extends JTable {

//keys
	/** @var int Primary key */
	var $id=null;
	/** @var varchar(255) */
	var $url=null;
  /** @var varchar(55) */
  var $lang=null;
  /** @var varchar(35) */
  var $hash_org=null;
  /** @var varchar(35) */
  var $hash_dest=null;
  /** @var BLOB */
  var $page_text=null;
  /** @var TEXT */
  var $cookies=null;
  /** @var TEXT */
  var $posts=null;
  /** @var boolean */
  var $manual_translated=null;
  /** @var boolean */
  var $use_as_base_url=null;
  /** @var boolean */
  var $use_orig_text=null;
  /** @var datetime */
  var $date=null;
  /** @var int */
  var $hits=null;
  /** @var boolean */
  var $published=null;
  /** @var boolean */
  var $approved=null;
  /** @var boolean */
  var $checked_out=null;
  /** @var checked_out_time */
  var $checked_out_time=null;

	/**
	* @param database - A database connector object
	*/
  function mosSefurl( &$db ) {
    parent::__construct( '#__seftranslate_urls', 'id', $db );
  }

  function loadForBaseUrl($hash_org){
      $this->_db->setQuery("SELECT id FROM #__seftranslate_urls WHERE hash_org = '$hash_org' and use_as_base_url=1 ");
      $id = intval( $this->_db->loadResult() );
    if ($id) {
      $this->load($id );
      return $this;
    }
    else return null;
  }
  function loadForHashDest($hash_dest){
      $this->_db->setQuery("SELECT id FROM #__seftranslate_urls WHERE hash_dest = '$hash_dest' ");
      $id = intval( $this->_db->loadResult() );
    if ($id) {
      $this->load($id );
      return $this;
    }
    else return null;
  }


}
